package com.link.base.core.basic.util.datax;

import java.util.ArrayList;
import java.util.List;

/**
 * 私人定制小程序
 * @author 何启谦
 * @date 2019/4/26
 */
public class SiRenDingZhi {

    /**
     * 私人定制 - 用户表字段映射
     *
     * @author heqiqian
     * @date 2019/04/23
     */
    public static String accntTemp() {
        //临时表主键名称
        String tempTablePrimaryKeyFieldName = "member_id";
        // 临时表名称
        String tempTableName = "srdz_member";
        // 正式表名称
        String targetTableName = "lnk_accnt";
        // 填充字段信息
        List<FieldMapping> fieldList = new ArrayList<>();

        fieldList.add(new FieldMapping("lc_last_sync_time", "syn_date", "DATETIME"));
        fieldList.add(new FieldMapping("reg_time", "qd_sync_date", "DATETIME"));
        fieldList.add(new FieldMapping("reg_time", "wx_subscribe_time", "DATETIME"));
        fieldList.add(new FieldMapping("member_name", "wx_nickname", "VARCHAR(255)"));
        fieldList.add(new FieldMapping("open_id", "wx_open_id", "VARCHAR(255)"));
        fieldList.add(new FieldMapping("uuid", "wx_unionid", "VARCHAR(300)"));
        fieldList.add(new FieldMapping("mobile", "mobile_phone", "varchar(50)"));
        fieldList.add(new FieldMapping("(case t1.sex when '0' then 'UNKNOWN' when '1' then 'MALE' when '2' then 'FEMALE' else t1.sex end)",
                "gender", "VARCHAR(10)"));
        fieldList.add(new FieldMapping("avatar", "wx_headimgurl", "VARCHAR(255)"));
        fieldList.add(new FieldMapping("country", "country", "VARCHAR(100)"));
        fieldList.add(new FieldMapping("province", "province", "VARCHAR(100)"));
        fieldList.add(new FieldMapping("city", "city", "VARCHAR(100)"));
        fieldList.add(new FieldMapping("'wxd99ea890f98497ca'", "ACCT_CHANNEL", "VARCHAR(100)"));
        fieldList.add(new FieldMapping("'wxd99ea890f98497ca'", "app_id", "VARCHAR(100)"));
        fieldList.add(new FieldMapping("'C'", "acct_level", "VARCHAR(50)"));
        fieldList.add(new FieldMapping("'MiniProgramsConsumer'", "acct_type", "VARCHAR(100)"));

        return DataxUtil.createProcedureCode(tempTablePrimaryKeyFieldName, tempTableName, targetTableName,
                fieldList, "ACCT_CHANNEL");
    }
}
